package com.baizhi.controller;


import com.baizhi.dto.PageDTO;
import com.baizhi.entity.Feedback;
import com.baizhi.service.FeedbackService;
import com.baizhi.vo.CommonResult;
import com.baizhi.vo.CommonResultPageVO;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@RestController  //将controller组件对象交给工厂管理
@CrossOrigin  //跨域 ： 当一个请求的url的协议、域名、端口三者之间任意一个与当前页面url不同即为跨域
@RequestMapping("feedback")
public class FeedbackController {

    @Resource
    FeedbackService feedbackService;


    //根据条件查询页码及相关数据
    @PostMapping("queryAllPage")
    public CommonResultPageVO queryAllPage(@RequestBody PageDTO pageDTO){

        System.out.println("pageDTO: "+pageDTO);

        return feedbackService.queryAllPage(pageDTO);
    }


    //删除一条数据
    @RequestMapping("delete")
    public CommonResult delete(@RequestBody Feedback feedback){
        System.out.println("feedback: "+feedback);

        try {
            feedbackService.delete(feedback);
            return CommonResult.success();
        } catch (Exception e) {
            e.printStackTrace();
            return CommonResult.faild();
        }
    }
}
